3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14 // http://doc.spip.org/@inc_meme_rubrique_dist
15 function inc_meme_rubrique_dist($id_rubrique, $id, $type, $order='', $limit=NULL, $ajax=false)
17 global $spip_lang_right, $spip_lang_left;
18 include_spip('inc/presentation');
19 include_spip('inc/afficher_objets');
21 $table = table_objet_sql($type);
22 if (!id_table_objet($table)) {
23 spip_log("meme_rubrique: $type table inconnue");
25 $table = 'spip_articles';
27 $prim = 'id_' . $type;
29 $limit = defined('_MAX_ART_AFFICHES') ? _MAX_ART_AFFICHES
: 10;
31 $titre = ($type!='syndic'?
'titre':'nom_site');
32 $exec = array('article'=>'articles','breve'=>'breves_voir','syndic'=>'sites');
34 $where = (($GLOBALS['visiteur_session']['statut'] == '0minirezo')
36 : "(statut = 'publie' OR statut = 'prop') AND ")
37 . "id_rubrique=$id_rubrique AND ($prim != $id)";
39 $select = "$prim AS id, $titre AS titre, statut";
41 $n = sql_countsel($table, $where);
45 if (!defined('_TRI_ARTICLES_RUBRIQUE')) define('_TRI_ARTICLES_RUBRIQUE', 'date DESC'); // surcharge possible dans mes_options.php
46 $order = ($order == '') ? _TRI_ARTICLES_RUBRIQUE
: "$order DESC";
47 $voss = sql_select($select, $table, $where, '', "$order", $limit);
51 $puce_statut = charger_fonction('puce_statut', 'inc');
52 $idom = 'rubrique_' . $type;
54 while($row = sql_fetch($voss)) {
56 $num = afficher_numero_edit($id, $prim, $type);
57 $statut = $row['statut'];
59 // Exception pour les meme-rubrique de sites
60 if ($type == "syndic") $type_statut = "site";
61 else $type_statut = $type;
63 $statut = $puce_statut($id, $statut, $id_rubrique, $type_statut);
64 $href = "<a class='verdana1' href='"
65 . generer_url_ecrire($exec[$type],"$prim=$id")
67 . sinon(typo($row['titre']), _T('info_sans_titre'))
70 // Todo: refaire en css plus sains
72 . "\n<div style='float:$spip_lang_right;width: 32%'>"
74 . "<div style='float:$spip_lang_left; padding-top:1px; width:18px;'>".$statut ."</div>"
75 . "<div style='padding-$spip_lang_left:18px;'>".$href."</div>"
76 . "<div style='clear:both; height: 3px;'></div>"
80 $icone = '<b>' . _T('info_meme_rubrique') . '</b>';
81 $bouton = bouton_block_depliable(_T('info_meme_rubrique'),true,'memerub');
84 debut_cadre('meme-rubriques',"article-24.gif",'',$bouton)
85 . debut_block_depliable(true,'memerub')
89 // $retour .= (($limit <= 0) ? '' : "<tr><td colspan='3' style='text-align: center'>+ $limit</td></tr>");
91 $retour .= fin_block()
92 . fin_cadre('meme-rubriques');
94 if ($ajax) return $retour;
96 // id utilise dans puce_statut_article
97 return "\n<div id='imgstatut$idom$id_rubrique'>$retour</div>";